<?php
require_once '../ptnhuan-web1/data/users.php';
?>

<link rel="stylesheet" type="text/css" href="public/css.css"> 
<div class="login-form">     
    <h1>Login</h1>


    <form method="POST">
        <table class="table">
            <tr>
                <td>Email Address: </td>
                <td><input id="username" name="username" type="text" size="45"></td>
            </tr>
            <tr>
                <td>Password: </td>
                <td><input id="password" name="password" type="password">
                    <a href="">Forgot your password?</a></td>
            </tr>
            <tr>
                <td></td>
                <td><input type="checkbox" name="checkbox" value="check ked"> 
                    Remember me on this computer </td>  
            </tr>
        </table>
        <p align="center"><input id="submit"   name="submit"   type="submit" value="Enter"></p>
    </form>
    
  
    <?php if (isset($_POST['submit'])): ?>
   
        <?php
        $username = $_POST['username'];
        $passwork = $_POST['password'];
        $flag = FALSE;
        $index = -1;

        for ($i = 0; $i < count($users); $i++) {
            if ((strcmp($users[$i]['username'], $username) == 0) &&
                    (strcmp($users[$i]['password'], $username) == 0)) {
                $flag = TRUE;
                $index = $i;
                
            }
        }
        
        if ($flag == true) {
            header("Location:http://localhost/truongcongthuc-web1/lamlai1.php?uid=" . $users[$index]['id']);
        } else {
            echo' Dang nhap that bai';
        }
        ?>   
    <?php endif; ?>